package models

import (
	log "github.com/astaxie/beego/logs"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

func Init(mysqlAuth string) {

	orm.Debug = false
	orm.RegisterDriver("mysql", orm.DRMySQL)
	maxIdle := 2
	maxConn := 10

	err := orm.RegisterDataBase("default", "mysql", mysqlAuth, maxIdle, maxConn)
	if err != nil {
		log.Error("init orm failed:%v", err)
	}

	orm.RegisterModel(new(Token), new(EthAddr), new(Transaction))
	orm.RunSyncdb("default", false, true)
}
